$(function(){
     getList()
});
//数据列表
function getList(){
	console.log("疫情管理");
    //构建列表
	$('#rolelist').getList({
        "initData": {
            "num": 1,
            "size": 10
          },
		"url":site.apiUrl+"/back/epidemicManage/selectEpidemicInfo",// 数据请求url
        "type":"POST",
        "ajaxform":true,
        "checkname": "datachk", //选择器名称，为空不显示选择器
        "checkattr": [ //选择器上增加自定义属性，以便传递多个参数
            { "attr": "id", "value": "{{id}}" },
          ],
        "col":[  //数据列
            {"field":"imgUrl","display":"图片","fun":"changePic"},
            {"field":"skipUrl","display":"跳转路径"},
            {"field":"isUsingDislpay","display":"状态"},
		],
		"option":[ //操作按钮配置
           {"icon":"edit","tip":"编辑","url":"add-epidemicManage.html?id={{id}}&scenicId={{scenicId}}"},  // 花括号内可以对应相关字段
			{"icon":"del","tip":"删除","fun":"deleteRole('{{id}}')"}
		]
	});
}

//删除
//批量删除
$("#batchDelBtn").click(function(){
    var c = "";
    $("input[name=datachk]:checked").each(function(){
        c += $(this).attr('id') + ',';
        console.log(c)
    });
    if(c!= null && c!=''){
        deleteRole(c);
    }else{
        ly.toast("请选择删除项");
    }
    
});
function deleteRole(id){
	var obj = {
		'ids':id,
		// 'deleteUserId':deleteUserId
	};
	var url = site.apiUrl+"/back/epidemicManage/deleteEpidemicManageByIds";
	ly.confirm("你确定删除吗？",function(){
		request({
	        url: url,
	        data:obj,
	        type: 'POST',
	        ajaxform:true,
	        callback: function(r) {
				if(r.code=="rest.success"){
					ly.toast('删除成功');
					$("#rolelist").getList.refresh();//刷新当前分页
	        	}else{
					ly.toast(data.result);
	        	}
	        }
		});
	});
}


function changePic(v, o, d) {
	console.log(d);
	if(d.imgUrl!=null && d.imgUrl!= ''){
		$(o).html("<img src="+d.imgUrl+" width='100'>");
	}else{
		$(o).html("<img src='"+site.interUrl+"images/default_head.jpg' width='50' height='50'>");
	}
    
}